package filmring

class ReviewController {

    def index = { }

    def review={
        FRUser user = FRUser.get(params.user as Long)
        Movie movie = Movie.get(params.movie as Long)
        Rating rating = Rating.findByUserAndMovie(user,movie)
        Review review = new Review(user:user, movie:movie, rating:rating, review:params.review)
        review.save()
        ActivityFeedEvent event = new ActivityFeedEvent(user:user, movie:movie, action:"${user.username} reviewed ${movie.title} on ${new Date().toTimestamp()}")
        event.save()
        redirect(controller: "movie", action: "show", params:[id:params.movie])
    }
}
